<%@ page import="com.pzhu.pojo.Book" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: Ice Bear
  Date: 2022/11/20
  Time: 23:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>

<head>
    <title>Ice Bear Library</title>

    <%
        if (session.getAttribute("login") == null) {
            request.getRequestDispatcher("/main").forward(request, response);
            return;
        }%>
    <script src="/library/layui-v2.7.6/layui/layui.js"></script>
    <link type="text/css" rel="stylesheet" href="/library/layui-v2.7.6/layui/css/layui.css"/>
</head>
<body>
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo layui-hide-xs layui-bg-black" >Ice Bear Library</div>
        <!-- 头部区域（可配合layui 已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
            <!-- 移动端显示 -->
            <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
                <i class="layui-icon layui-icon-spread-left"></i>
            </li>
            <li class="layui-nav-item layui-hide-xs"><a href="javascript:;">当前在线人数:${applicationScope.get("allUserCount")}</a></li>


            <li class="layui-nav-item">
                <a href="javascript:;">图书管理</a>
                <dl class="layui-nav-child">
                    <dd><a href="/library/view/jsp/book/findBook.jsp">查询</a></dd>
                    <dd><a href="/library/view/jsp/book/addBook.jsp">增加</a></dd>
                    <dd><a href="/library/view/jsp/book/updateBook.jsp">修改</a></dd>
                    <dd><a href="/library/view/jsp/book/deleteBook.jsp">删除</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item"><a href="/library/show-all-books;">总览</a></li>
            <li class="layui-nav-item"><a href="">访问人数:${applicationScope.get("loginCount")}</a></li>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item layui-hide layui-show-md-inline-block">
                <a href="javascript:;">
                    <img src="//tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg" class="layui-nav-img">
                    ${sessionScope.get("Uname")}
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="/library/logout">退出登录</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
                <a href="javascript:;">
                    <i class="layui-icon layui-icon-more-vertical">
                    </i>
                </a>
            </li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                <li class="layui-nav-item layui-nav-itemed">
                    <a class="" href="javascript:;">图书管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="/library/view/jsp/book/findBook.jsp">查询</a></dd>
                        <dd><a href="/library/view/jsp/book/addBook.jsp">增加</a></dd>
                        <dd><a href="/library/view/jsp/book/updateBook.jsp">修改</a></dd>
                        <dd><a href="/library/view/jsp/book/deleteBook.jsp">删除</a></dd>
                    </dl>
                </li>

                <li class="layui-nav-item"><a href="/library/show-all-books;">总览</a></li>
                <li class="layui-nav-item"><a href="">在线人数:${applicationScope.get("allUserCount")}</a></li>
                <li class="layui-nav-item"><a href="">访问人数:${applicationScope.get("allUserCount")}</a></li>
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <div class="layui-card-body">
            <table lay-filter="demo" id="dataTable">
                <thead>
                <th lay-data="{field:'id',width:100}">编号</th>
                <th lay-data="{field:'name',width:100}">书名</th>
                <th lay-data="{field:'author',width:100}">作者</th>
                <th lay-data="{field:'number',width:60}">数量</th>
                <th lay-data="{field:'classId',width:60}">分类</th>
                <th lay-data="{field:'price',width:60}">价格</th>
                <th lay-data="{field:'publish',width:200}">出版社</th>
                <th lay-data="{field:'pubDate',width:150}">出版时间</th>
                <th lay-data="{field:'language',width:100}">语言</th>
                <th lay-data="{field:'ISBN',width:140}">ISBN</th>
                <th lay-data="{field:'introduction',width:400}">介绍</th>
                <th lay-data="{field:'updateName',width:400}">上传用户</th>
                </thead>
                <tbody>
                <%
                    List<Book> list = (List<Book>) request.getAttribute("bookList");
                    for (int i = 0; i < list.size(); i++) {
                %>

                <tr>
                    <td><%=list.get(i).getId()%>
                    </td>
                    <td><%=list.get(i).getName()%>
                    </td>
                    <td><%=list.get(i).getAuthor()%>
                    </td>
                    <td><%=list.get(i).getNumber()%>
                    </td>
                    <td><%=list.get(i).getClassId()%>
                    </td>
                    <td><%=list.get(i).getPrice()%>
                    </td>
                    <td><%=list.get(i).getPublish()%>
                    </td>
                    <td><%=list.get(i).getPubDate()%>
                    </td>
                    <td><%=list.get(i).getLanguage()%>
                    </td>
                    <td><%=list.get(i).getISBN()%>
                    </td>
                    <td><%=list.get(i).getIntroduction()%>
                    </td>
                    <td><%=list.get(i).getUpdateName()%>
                    </td>
                </tr>

                <%
                    }
                %>
                </tbody>
            </table>
        </div>
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        底部固定区域
    </div>
</div>
<script>
    //JS
    layui.use(['element', 'layer', 'util'], function(){
        var element = layui.element
            ,layer = layui.layer
            ,util = layui.util
            ,$ = layui.$;

        //头部事件
        util.event('lay-header-event', {
            //左侧菜单事件
            menuLeft: function(othis){
                layer.msg('展开左侧菜单的操作', {icon: 0});
            }
            ,menuRight: function(){
                layer.open({
                    type: 1
                    ,content: '<div style="padding: 15px;">处理右侧面板的操作</div>'
                    ,area: ['260px', '100%']
                    ,offset: 'rt' //右上角
                    ,anim: 5
                    ,shadeClose: true
                });
            }
        });

    });


    var table = layui.table;
    //转换静态表格
    table.init('demo', {
        // cellMinWidth: 60
        height: 800 //设置高度
        , limit: 100 //注意：请务必确保 limit 参数（默认：10）是与你服务端限定的数据条数一致
        //支持所有基础参数
    })

</script>

</body>
</html>
